package com.caine.androidtask.ls22;

import com.caine.androidtask.R;
import com.caine.androidtask.ls23.ScreenOnOrOffReceiver;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class TestMySwitchButton extends Activity {
private MySwitchButton switch_btn;
private boolean flag = false;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.caine_ls22);
		switch_btn = (MySwitchButton) findViewById(R.id.switchbtn);
		switch_btn.setText("SWITCH BUTTON");
		switch_btn.setImageResource(R.drawable.icons);
		
		switch_btn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Toast.makeText(TestMySwitchButton.this, "TestMySwitchButton btn init !", Toast.LENGTH_SHORT).show();
			}
		});
		switch_btn.setBtnOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//Toast.makeText(context, "MySwitchButton btn init !", Toast.LENGTH_SHORT).show();
				flag = !flag;
				if(flag){
					switch_btn.setImageResource(R.drawable.apk);
				//  flag = false;
				}else{
					switch_btn.setImageResource(R.drawable.icons);
				// flag = true;
				}
				
			}
		});
	}
	
}
